<template>
  <view class="Authentication">
    <view class="u-search">
      <u-search
        bgColor="#fff"
        borderColor="#eee"
        height="80"
        shape="square"
        @custom="searchLiat"
      ></u-search>
    </view>
    <view class="SQList">
      <ul v-if="isShow">
        <view style="clear: both">
          <li
            v-for="(item, index) in contentData2"
            v-show="contentData2.length > 0 && item.show"
            @click="contentDataClick(item)"
            :key="index"
          >
            <p style="font-weight: bold; height: 28px">
              <span
                style="
                  float: left;
                  display: block;
                  height: 20px;
                  width: 50%;
                  overflow: hidden;
                  text-overflow: ellipsis;
                  white-space: nowrap;
                "
                >{{ item.qymc }}</span
              >
              <span style="float: right">{{ plusXing(item.tyshxydm) }}</span>
            </p>
            <p style="font-size: 16px; color: #848484; height: 20px">
              <span style="float: left">注册地：{{ item.areaid }}</span>
              <span style="float: right">法人代表：{{ item.frdb }}</span>
            </p>
            <p style="font-size: 16px; color: #848484; height: 20px">
              <span style="float: left">资质类别：{{ item.zzlb }}</span>
            </p>
            <!-- <p style="font-size: 14px; color: #848484; height: 20px;padding-top: 8px;">
              <span style="float: left">通讯地址：{{
              item.areaid ? item.areaid : "暂无数据"
              }}</span>
            </p> -->
          </li>
        </view>
        <view
          style="height: 60vh; text-align: center; padding-top: 20vh"
          v-show="noData"
        >
          <view style="margin-bottom: 10px">
            <img
              src="https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/DSF/50.png"
            />
          </view>
          <view>暂无数据</view>
        </view>
      </ul>
    </view>
  </view>
</template>


<script>
import {
  getDatalistForTree,
  findCompanyInformation,
  ECAOpenDataView,
  getServiceData,
} from "@/common/utils/api.js";
export default {
  data() {
    return {
      comments: "",
      noData: false,
      isShow: true,
      contentData2: [],
    };
  },
  methods: {
    contentDataClick(data) {
      uni.setStorageSync("itemData", data);
      if (this.comments != "applyAppraisal") {
        this.$nextTick(() => {
          uni.navigateTo({
            url: "/pages/Authentication/details?component=" + this.comments,
          });
        });
      } else {
        this.$nextTick(() => {
          uni.navigateTo({
            url: "/pages/Authentication/details",
          });
        });
      }
    },
    searchLiat(data) {
      if (data) {
        this.isShow = false;
        this.contentData2.forEach((item) => {
          if (
            item.qymc.indexOf(data) > -1 ||
            item.frdb.indexOf(data) > -1 ||
            item.areaid.indexOf(data) > -1 ||
            item.zzlb.indexOf(data) > -1
          ) {
          } else {
            item.show = false;
          }
        });
        console.log(this.contentData2, "xiaohe");
        this.isShow = true;
      } else {
        // 清空保留左边原本有的数据
        this.isShow = false;
        this.contentData2.forEach((item) => {
          item.show = true;
        });
        this.isShow = true;
      }
    },
    plusXing(str, frontLen, endLen) {
      //浙里办新规则
      if (str.length < 9) {
        return "*" + str.substring(1, str.length); //截取name 字符串截取第一个字符
      } else if (str.length > 9 && str.length < 18) {
        return str.substring(0, 3) + "****" + str.substring(7, str.length); //截取第一个和大于第4个字符
      } else {
        return (
          str.substring(0, 1) +
          "****************" +
          str.substring(str.length - 1, str.length)
        );
      }
    },
    async getdata(data) {
      let data1 = {
        params: { areaid: "" },
        serviceOrder: 1,
      };
      if (!data) {
        //从申请件的过程中获取
        const res = await getServiceData(data1);
        this.contentData2 = JSON.parse(res.data.desc);
        this.contentData2.forEach((item) => {
          item.show = true;
        });
        console.log(this.contentData2, "xiaohe");
      } else {
        let daat2 = {
          params: { filing_id: data },
          serviceOrder: 2,
        };
        const res = getServiceData(daat2);
      }
      // this.contentData2 = res
    },
  },
  onLoad(options) {
    this.getdata();
    this.comments = options.component;
    if (ZWJSBridge) {
      ZWJSBridge.setTitle({
        title: "鉴定公司",
      })
        .then((res) => {})
        .catch((err) => {});
    }
  },
};
</script>


<style lang="scss" scoped>
.Authentication {
  width: 100%;
  height: 100vh;
  overflow: auto;
  background: #eee;

  .SQList {
    width: 100vw;
    overflow-x: hidden;
    overflow-y: auto;
    background: #eee;

    li {
      //   padding-top: 4px;
      background-color: white;
      border-radius: 10px;
      padding: 10px 10px 16px 10px;
      width: 96%;
      overflow: hidden;
      margin: 0 auto;
      margin-top: 0.6rem;
      color: black;
      box-shadow: 0 0 0.16rem #e3e3e3;
    }
  }

  .u-search {
    padding: 0.2rem;
  }
}
</style>